home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_008 / src / hack.shk.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  15KB  |  649 lines

  1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
  2.  
  3. #include "hack.h"
  4. #ifdef QUEST
  5. int shlevel = 0;
  6. struct monst *shopkeeper = 0;
  7. struct obj *billobjs = 0;
  8. obfree(obj,merge) register struct obj *obj, *merge; {
  9.     free((char *) obj);
  10. }
  11. inshop(){ return(0); }
  12. addtobill(){}
  13. subfrombill(){}
  14. splitbill(){}
  15. dopay(){}
  16. paybill(){}
  17. doinvbill(){}
  18. shkdead(){}
  19. shk_move(){ return(0); }
  20. setshk(){}
  21. char *shkname(){ return(""); }
  22.  
  23. #else
  24. #include    "hack.mfndpos.h"
  25. #include    "def.eshk.h"
  26.  
  27. #define    ESHK    ((struct eshk *)(&(shopkeeper->mextra[0])))
  28. #define    NOTANGRY    shopkeeper->mpeaceful
  29. #define    ANGRY    !NOTANGRY
  30.  
  31. extern char plname[];
  32. extern struct obj *o_on();
  33. struct monst *shopkeeper = 0;
  34. struct bill_x *bill;
  35. int shlevel = 0;    /* level of this shopkeeper */
  36. struct obj *billobjs;    /* objects on bill with bp->useup */
  37. /* #define    billobjs    shopkeeper->minvent
  38.    doesnt work so well, since we do not want these objects to be dropped
  39.    when the shopkeeper is killed.
  40.    (See also the save and restore routines.)
  41.  */
  42.  
  43. /* invariants: obj->unpaid iff onbill(obj) [unless bp->useup]
  44.         obj->quan <= bp->bquan
  45.  */
  46.  
  47. long int total;
  48.  
  49. char shtypes[] = "=/)%?!["; /* 8 shoptypes: 7 specialized, 1 mixed */
  50. char *shopnam[] = {
  51.     "engagement ring", "walking cane", "antique weapon",
  52.     "delicatessen", "second hand book", "liquor",
  53.     "used armor", "assorted antiques"
  54. };
  55.  
  56. char *
  57. shkname() {
  58.     return(ESHK->shknam);
  59. }
  60.  
  61. shkdead(){
  62.     rooms[ESHK->shoproom].rtype = 0;
  63.     setpaid();
  64.     shopkeeper = 0;
  65.     bill = (struct bill_x *) -1000;    /* dump core when referenced */
  66. }
  67.  
  68. setpaid(){    /* caller has checked that shopkeeper exists */
  69. register struct obj *obj;
  70.     for(obj = invent; obj; obj = obj->nobj)
  71.         obj->unpaid = 0;
  72.     for(obj = fobj; obj; obj = obj->nobj)
  73.         obj->unpaid = 0;
  74.     while(obj = billobjs){
  75.         billobjs = obj->nobj;
  76.         free((char *) obj);
  77.     }
  78.     ESHK->billct = 0;
  79. }
  80.  
  81. addupbill(){    /* delivers result in total */
  82.         /* caller has checked that shopkeeper exists */
  83. register int ct = ESHK->billct;
  84. register struct bill_x *bp = bill;
  85.     total = 0;
  86.     while(ct--){
  87.         total += bp->price * bp->bquan;
  88.         bp++;
  89.     }
  90. }
  91.  
  92. inshop(){
  93. register int tmp = inroom(u.ux,u.uy);
  94.     if(tmp < 0 || rooms[tmp].rtype < 8) {
  95.         u.uinshop = 0;
  96.         if(shopkeeper && ESHK->billct){
  97.             pline("Somehow you escaped the shop without paying!");
  98.             addupbill();
  99.             pline("You stole for a total worth of %lu zorkmids.",
  100.                 total);
  101.             ESHK->robbed += total;
  102.             setpaid();
  103.         }
  104.         if(tmp >= 0 && rooms[tmp].rtype == 7){
  105.             register struct monst *mtmp;
  106.             pline("Welcome to David's treasure zoo!");
  107.             rooms[tmp].rtype = 0;
  108.             for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  109.                 if(!rn2(4)) mtmp->msleep = 0;
  110.         }
  111.     } else {
  112.         if(shlevel != dlevel) setshk();
  113.         if(!shopkeeper) u.uinshop = 0;
  114.         else if(!u.uinshop){
  115.             if(!ESHK->visitct ||
  116.                 strncmp(ESHK->customer, plname, PL_NSIZ)){
  117.                 /* He seems to be new here */
  118.                 ESHK->visitct = 0;
  119.                 (void) strncpy(ESHK->customer,plname,PL_NSIZ);
  120.                 NOTANGRY = 1;
  121.             }
  122.             pline("Hello %s! Welcome%s to %s's %s shop!",
  123.                 plname,
  124.                 ESHK->visitct++ ? " again" : "",
  125.                 shkname(),
  126.                 shopnam[rooms[ESHK->shoproom].rtype - 8] );
  127.             u.uinshop = 1;
  128.         }
  129.     }
  130.     return(u.uinshop);
  131. }
  132.  
  133. setshk(){
  134. register struct monst *mtmp;
  135.     for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) if(mtmp->isshk){
  136.         shopkeeper = mtmp;
  137.         bill = &(ESHK->bill[0]);
  138.         shlevel = dlevel;
  139.         if(ANGRY && strncpy(ESHK->customer,plname,PL_NSIZ))
  140.             NOTANGRY = 1;
  141.         billobjs = 0;
  142.         return;
  143.     }
  144.     shopkeeper = 0;
  145.     bill = (struct bill_x *) -1000;    /* dump core when referenced */
  146. }
  147.  
  148. struct bill_x *
  149. onbill(obj) register struct obj *obj; {
  150. register struct bill_x *bp;
  151.     if(!shopkeeper) return(0);
  152.     for(bp = bill; bp < &bill[ESHK->billct]; bp++)
  153.         if(bp->bo_id == obj->o_id) {
  154.             if(!obj->unpaid) pline("onbill: paid obj on bill?");
  155.             return(bp);
  156.         }
  157.     if(obj->unpaid) pline("onbill: unpaid obj not on bill?");
  158.     return(0);
  159. }
  160.  
  161. /* called with two args on merge */
  162. obfree(obj,merge) register struct obj *obj, *merge; {
  163. register struct bill_x *bp = onbill(obj);
  164. register struct bill_x *bpm;
  165.     if(bp) {
  166.         if(!merge){
  167.             bp->useup = 1;
  168.             obj->unpaid = 0;    /* only for doinvbill */
  169.             obj->nobj = billobjs;
  170.             billobjs = obj;
  171.             return;
  172.         }
  173.         bpm = onbill(merge);
  174.         if(!bpm){
  175.             /* this used to be a rename */
  176.             impossible();
  177.             return;
  178.         } else {
  179.             /* this was a merger */
  180.             bpm->bquan += bp->bquan;
  181.             ESHK->billct--;
  182.             *bp = bill[ESHK->billct];
  183.         }
  184.     }
  185.     free((char *) obj);
  186. }
  187.  
  188. pay(tmp) long tmp; {
  189.     u.ugold -= tmp;
  190.     shopkeeper->mgold += tmp;
  191.     flags.botl = 1;
  192. }
  193.  
  194. dopay(){
  195. long ltmp;
  196. register struct bill_x *bp;
  197. int shknear = (shlevel == dlevel && shopkeeper &&
  198.     dist(shopkeeper->mx,shopkeeper->my) < 3);
  199. int pass, tmp;
  200.  
  201.     multi = 0;
  202.     if(!inshop() && !shknear) {
  203.         pline("You are not in a shop.");
  204.         return(0);
  205.     }
  206.     if(!shknear &&
  207.         inroom(shopkeeper->mx,shopkeeper->my) != ESHK->shoproom){
  208.         pline("There is nobody here to receive your payment.");
  209.         return(0);
  210.     }
  211.     if(!ESHK->billct){
  212.         pline("You do not owe %s anything.", monnam(shopkeeper));
  213.         if(!u.ugold){
  214.             pline("Moreover, you have no money.");
  215.             return(1);
  216.         }
  217.         if(ESHK->robbed){
  218.             pline("But since the shop has been robbed recently,");
  219.             pline("you %srepay %s's expenses.",
  220.                 (u.ugold < ESHK->robbed) ? "partially " : "",
  221.                 monnam(shopkeeper));
  222.             pay((u.ugold<ESHK->robbed) ? u.ugold : ESHK->robbed);
  223.             ESHK->robbed = 0;
  224.             return(1);
  225.         }
  226.         if(ANGRY){
  227.             pline("But in order to appease %s,",
  228.                 amonnam(shopkeeper, "angry"));
  229.             if(u.ugold >= 1000){
  230.                 ltmp = 1000;
  231.                 pline(" you give him 1000 gold pieces.");
  232.             } else {
  233.                 ltmp = u.ugold;
  234.                 pline(" you give him all your money.");
  235.             }
  236.             pay(ltmp);
  237.             if(rn2(3)){
  238.                 pline("%s calms down.", Monnam(shopkeeper));
  239.                 NOTANGRY = 1;
  240.             } else    pline("%s is as angry as ever.",
  241.                     Monnam(shopkeeper));
  242.         }
  243.         return(1);
  244.     }
  245.     for(pass = 0; pass <= 1; pass++) {
  246.         tmp = 0;
  247.         while(tmp < ESHK->billct) {
  248.             bp = &bill[tmp];
  249.             if(!pass && !bp->useup) {
  250.                 tmp++;
  251.                 continue;
  252.             }
  253.             if(!dopayobj(bp)) return(1);
  254.             bill[tmp] = bill[--ESHK->billct];
  255.         }
  256.     }
  257.     pline("Thank you for shopping in %s's %s store!",
  258.         shkname(),
  259.         shopnam[rooms[ESHK->shoproom].rtype - 8]);
  260.     NOTANGRY = 1;
  261.     return(1);
  262. }
  263.  
  264. /* return 1 if paid successfully */
  265. /*        0 if not enough money */
  266. /*       -1 if object could not be found (but was paid) */
  267. dopayobj(bp) register struct bill_x *bp; {
  268. register struct obj *obj;
  269. long ltmp;
  270.  
  271.     /* find the object on one of the lists */
  272.     if(bp->useup)
  273.         obj = o_on(bp->bo_id, billobjs);
  274.     else if(!(obj = o_on(bp->bo_id, invent)) &&
  275.         !(obj = o_on(bp->bo_id, fobj)) &&
  276.         !(obj = o_on(bp->bo_id, fcobj))) {
  277.             register struct monst *mtmp;
  278.             for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  279.             if(obj = o_on(bp->bo_id, mtmp->minvent))
  280.                 break;
  281.             for(mtmp = fallen_down; mtmp; mtmp = mtmp->nmon)
  282.             if(obj = o_on(bp->bo_id, mtmp->minvent))
  283.                 break;
  284.         }
  285.     if(!obj) {
  286.         pline("Shopkeeper administration out of order.");
  287.         impossible();
  288.         setpaid();    /* be nice to the player */
  289.         return(0);
  290.     }
  291.  
  292.     if(!obj->unpaid && !bp->useup){
  293.         pline("Paid object on bill??");
  294.         impossible();
  295.         return(1);
  296.     }
  297.     obj->unpaid = 0;
  298.     ltmp = bp->price * bp->bquan;
  299.     if(ANGRY) ltmp += ltmp/3;
  300.     if(u.ugold < ltmp){
  301.         pline("You don't have gold enough to pay %s.",
  302.             doname(obj));
  303.         obj->unpaid = 1;
  304.         return(0);
  305.     }
  306.     pay(ltmp);
  307.     pline("You bought %s for %ld gold piece%s.",
  308.         doname(obj), ltmp, (ltmp == 1) ? "" : "s");
  309.     if(bp->useup) {
  310.         register struct obj *otmp = billobjs;
  311.         if(obj == billobjs)
  312.             billobjs = obj->nobj;
  313.         else {
  314.             while(otmp && otmp->nobj != obj) otmp = otmp->nobj;
  315.             if(otmp) otmp->nobj = obj->nobj;
  316.             else pline("Error in shopkeeper administration");
  317.         }
  318.         free((char *) obj);
  319.     }
  320.     return(1);
  321. }
  322.  
  323. /* routine called after dying (or quitting) with nonempty bill */
  324. paybill(){
  325.     if(shopkeeper && ESHK->billct){
  326.         addupbill();
  327.         if(total > u.ugold){
  328.             shopkeeper->mgold += u.ugold;
  329.             u.ugold = 0;
  330.         pline("%s comes and takes all your possessions.",
  331.             Monnam(shopkeeper));
  332.         } else {
  333.             u.ugold -= total;
  334.             shopkeeper->mgold += total;
  335.     pline("%s comes and takes the %ld zorkmids you owed him.",
  336.         Monnam(shopkeeper), total);
  337.         }
  338.         setpaid();    /* in case we create bones */
  339.     }
  340. }
  341.  
  342. /* called in hack.c when we pickup an object */
  343. addtobill(obj) register struct obj *obj; {
  344. register struct bill_x *bp;
  345.     if(!inshop() || (u.ux == ESHK->shk.x && u.uy == ESHK->shk.y) ||
  346.         (u.ux == ESHK->shd.x && u.uy == ESHK->shd.y) ||
  347.         onbill(obj) /* perhaps we threw it away earlier */
  348.     ) return;
  349.     if(ESHK->billct == BILLSZ){
  350.         pline("You got that for free!");
  351.         return;
  352.     }
  353.     bp = &bill[ESHK->billct];
  354.     bp->bo_id = obj->o_id;
  355.     bp->bquan = obj->quan;
  356.     bp->useup = 0;
  357.     bp->price = getprice(obj);
  358.     ESHK->billct++;
  359.     obj->unpaid = 1;
  360. }
  361.  
  362. splitbill(obj,otmp) register struct obj *obj, *otmp; {
  363.     /* otmp has been split off from obj */
  364. register struct bill_x *bp;
  365. register int tmp;
  366.     bp = onbill(obj);
  367.     if(!bp) { impossible(); return; }
  368.     if(bp->bquan < otmp->quan) {
  369.         pline("Negative quantity on bill??");
  370.         impossible();
  371.     }
  372.     if(bp->bquan == otmp->quan) {
  373.         pline("Zero quantity on bill??");
  374.         impossible();
  375.     }
  376.     bp->bquan -= otmp->quan;
  377.  
  378.     /* addtobill(otmp); */
  379.     if(ESHK->billct == BILLSZ) otmp->unpaid = 0;
  380.     else {
  381.         tmp = bp->price;
  382.         bp = &bill[ESHK->billct];
  383.         bp->bo_id = otmp->o_id;
  384.         bp->bquan = otmp->quan;
  385.         bp->useup = 0;
  386.         bp->price = tmp;
  387.         ESHK->billct++;
  388.     }
  389. }
  390.  
  391. subfrombill(obj) register struct obj *obj; {
  392. long ltmp;
  393. register int tmp;
  394. register struct obj *otmp;
  395. register struct bill_x *bp;
  396.     if(!inshop() || (u.ux == ESHK->shk.x && u.uy == ESHK->shk.y) ||
  397.         (u.ux == ESHK->shd.x && u.uy == ESHK->shd.y))
  398.         return;
  399.     if((bp = onbill(obj)) != 0){
  400.         obj->unpaid = 0;
  401.         if(bp->bquan > obj->quan){
  402.             otmp = newobj(0);
  403.             *otmp = *obj;
  404.             bp->bo_id = otmp->o_id = flags.ident++;
  405.             otmp->quan = (bp->bquan -= obj->quan);
  406.             otmp->owt = 0;    /* superfluous */
  407.             otmp->onamelth = 0;
  408.             bp->useup = 1;
  409.             otmp->nobj = billobjs;
  410.             billobjs = otmp;
  411.             return;
  412.         }
  413.         ESHK->billct--;
  414.         *bp = bill[ESHK->billct];
  415.         return;
  416.     }
  417.     if(obj->unpaid){
  418.         pline("%s didn't notice.", Monnam(shopkeeper));
  419.         obj->unpaid = 0;
  420.         return;        /* %% */
  421.     }
  422.     /* he dropped something of his own - probably wants to sell it */
  423.     if(shopkeeper->msleep || shopkeeper->mfroz ||
  424.         inroom(shopkeeper->mx,shopkeeper->my) != ESHK->shoproom)
  425.         return;
  426.     if(ESHK->billct == BILLSZ ||
  427.       ((tmp = shtypes[rooms[ESHK->shoproom].rtype-8]) && tmp != obj->olet)
  428.       || index("_0", obj->olet)) {
  429.         pline("%s seems not interested.", Monnam(shopkeeper));
  430.         return;
  431.     }
  432.     ltmp = getprice(obj) * obj->quan;
  433.     if(ANGRY) {
  434.         ltmp /= 3;
  435.         NOTANGRY = 1;
  436.     } else    ltmp /= 2;
  437.     if(ESHK->robbed){
  438.         if((ESHK->robbed -= ltmp) < 0) ESHK->robbed = 0;
  439. pline("Thank you for your contribution to restock this recently plundered shop.");
  440.         return;
  441.     }
  442.     if(ltmp > shopkeeper->mgold) ltmp = shopkeeper->mgold;
  443.     pay(-ltmp);
  444.     if(!ltmp)
  445.     pline("%s gladly accepts %s but cannot pay you at present.",
  446.         Monnam(shopkeeper), doname(obj));
  447.     else
  448.     pline("You sold %s and got %ld gold piece%s.", doname(obj), ltmp,
  449.         (ltmp == 1) ? "" : "s");
  450. }
  451.  
  452. doinvbill(cl) int cl; {
  453. register unsigned tmp,cnt = 0;
  454. register struct obj *obj;
  455. char buf[BUFSZ];
  456.     if(!shopkeeper) return;
  457.     for(tmp = 0; tmp < ESHK->billct; tmp++) if(bill[tmp].useup) cnt++;
  458.     if(!cnt) return;
  459.     if(!cl && !flags.oneline) cls();
  460.     if(!flags.oneline) myputs("\n\nUnpaid articles already used up:\n");
  461.     for(tmp = 0; tmp < ESHK->billct; tmp++) if(bill[tmp].useup){
  462.         for(obj = billobjs; obj; obj = obj->nobj)
  463.             if(obj->o_id == bill[tmp].bo_id) break;
  464.         if(!obj) {
  465.             pline("Bad shopkeeper administration.");
  466.             impossible();
  467.             return;
  468.         }
  469.         (void) sprintf(buf, "* -  %s", doname(obj));
  470.         for(cnt=0; buf[cnt]; cnt++);
  471.         while(cnt < 50) buf[cnt++] = ' ';
  472.         (void) sprintf(&buf[cnt], " %5d zorkmids",
  473.                 bill[tmp].price * bill[tmp].bquan);
  474.         if(flags.oneline)
  475.             pline(buf);
  476.         else
  477.             myputs(buf);
  478.     }
  479.     if(!cl && !flags.oneline) {
  480.         getret();
  481.         docrt();
  482.     }
  483. }
  484.  
  485. getprice(obj) register struct obj *obj; {
  486. register int tmp,ac;
  487.     switch(obj->olet){
  488.         case AMULET_SYM:
  489.             tmp = 10*rnd(500);
  490.             break;
  491.         case TOOL_SYM:
  492.             tmp = 10*rnd(150);
  493.             break;
  494.         case RING_SYM:
  495.             tmp = 10*rnd(100);
  496.             break;
  497.         case WAND_SYM:
  498.             tmp = 10*rnd(100);
  499.             break;
  500.         case SCROLL_SYM:
  501.             tmp = 10*rnd(50);
  502.             break;
  503.         case POTION_SYM:
  504.             tmp = 10*rnd(50);
  505.             break;
  506.         case FOOD_SYM:
  507.             tmp = 10*rnd(5 + (2000/realhunger()));
  508.             break;
  509.         case GEM_SYM:
  510.             tmp = 10*rnd(20);
  511.             break;
  512.         case ARMOR_SYM:
  513.             ac = 10 - obj->spe;
  514.             tmp = 100 + (10-ac)*(10-ac)*rnd(20-ac);
  515.             break;
  516.         case WEAPON_SYM:
  517.             if(obj->otyp < BOOMERANG)
  518.                 tmp = 5*rnd(10);
  519.             else if(obj->otyp == LONG_SWORD ||
  520.                 obj->otyp == TWO_HANDED_SWORD)
  521.                 tmp = 10*rnd(150);
  522.             else    tmp = 10*rnd(75);
  523.             break;
  524.         case CHAIN_SYM:
  525.             pline("Strange ..., carrying a chain?");
  526.         case BALL_SYM:
  527.             tmp = 10;
  528.             break;
  529.         default:
  530.             tmp = 10000;
  531.     }
  532.     return(tmp);
  533. }
  534.  
  535. realhunger(){    /* not completely foolproof */
  536. register int tmp = u.uhunger;
  537. register struct obj *otmp = invent;
  538.     while(otmp){
  539.         if(otmp->olet == FOOD_SYM && !otmp->unpaid)
  540.             tmp += objects[otmp->otyp].nutrition;
  541.         otmp = otmp->nobj;
  542.     }
  543.     return((tmp <= 0) ? 1 : tmp);
  544. }
  545.  
  546. shk_move(){
  547. register struct monst *mtmp;
  548. register struct permonst *mdat = shopkeeper->data;
  549. register xchar gx,gy,omx,omy,nx,ny,nix,niy;
  550. register schar appr,i;
  551. schar shkr,tmp,chi,chcnt,cnt;
  552. boolean uondoor, avoid;
  553. coord poss[9];
  554. int info[9];
  555.     omx = shopkeeper->mx;
  556.     omy = shopkeeper->my;
  557.     shkr = inroom(omx,omy);
  558.     if(ANGRY && dist(omx,omy) < 3){
  559.         (void) hitu(shopkeeper, d(mdat->damn, mdat->damd)+1);
  560.         return(0);
  561.     }
  562.     appr = 1;
  563.     gx = ESHK->shk.x;
  564.     gy = ESHK->shk.y;
  565.     if(ANGRY){
  566.         long saveBlind = Blind;
  567.         Blind = 0;
  568.         if(shopkeeper->mcansee && !Invis && cansee(omx,omy)) {
  569.             gx = u.ux;
  570.             gy = u.uy;
  571.         }
  572.         Blind = saveBlind;
  573.         avoid = FALSE;
  574.     } else {
  575. #define    GDIST(x,y)    ((x-gx)*(x-gx)+(y-gy)*(y-gy))
  576.         if(Invis)
  577.           avoid = FALSE;
  578.         else {
  579.           uondoor = (u.ux == ESHK->shd.x && u.uy == ESHK->shd.y);
  580.           avoid = ((u.uinshop && dist(gx,gy) > 8) || uondoor);
  581.           if(((!ESHK->robbed && !ESHK->billct) || avoid)
  582.               && GDIST(omx,omy) < 3){
  583.               if(!online(omx,omy)) return(0);
  584.               if(omx == gx && omy == gy)
  585.                   appr = gx = gy = 0;
  586.           }
  587.         }
  588.     }
  589.     if(omx == gx && omy == gy) return(0);
  590.     if(shopkeeper->mconf) appr = 0;
  591.     nix = omx;
  592.     niy = omy;
  593.     cnt = mfndpos(shopkeeper,poss,info,
  594.         (avoid ? NOTONL : 0) | ALLOW_SSM);
  595.     if(cnt == 0 && avoid && uondoor)
  596.         cnt = mfndpos(shopkeeper,poss,info,ALLOW_SSM);
  597.     chi = -1;
  598.     chcnt = 0;
  599.     for(i=0; i<cnt; i++){
  600.         nx = poss[i].x;
  601.         ny = poss[i].y;
  602.            if((tmp = levl[nx][ny].typ) = ROOM ||
  603.         (shkr != ESHK->shoproom && (tmp==CORR || tmp==DOOR)))
  604. #ifdef STUPID
  605.         /* cater for stupid compilers */
  606.         { int zz;
  607.         if((!appr && !rn2(++chcnt)) ||
  608.            (appr && (zz = GDIST(nix,niy)) && zz > GDIST(nx,ny))){
  609. #else
  610.         if((!appr && !rn2(++chcnt)) ||
  611.            (appr && GDIST(nx,ny) < GDIST(nix,niy))){
  612. #endif STUPID
  613.             nix = nx;
  614.             niy = ny;
  615.             chi = i;
  616. #ifdef STUPID
  617.            }
  618. #endif STUPID
  619.         }
  620.     }
  621.     if(nix != omx || niy != omy){
  622.         if(info[chi] & ALLOW_M){
  623.             mtmp = m_at(nix,niy);
  624.             if(hitmm(shopkeeper,mtmp) == 1 && rn2(3) &&
  625.                hitmm(mtmp,shopkeeper) == 2) return(2);
  626.             return(0);
  627.         } else if(info[chi] & ALLOW_U){
  628.             (void) hitu(shopkeeper, d(mdat->damn, mdat->damd)+1);
  629.             return(0);
  630.         }
  631.         shopkeeper->mx = nix;
  632.         shopkeeper->my = niy;
  633.         pmon(shopkeeper);
  634.         return(1);
  635.     }
  636.     return(0);
  637. }
  638. #endif QUEST
  639.  
  640. char *
  641. plur(n) unsigned n; {
  642.     return((n==1) ? "" : "s");
  643. }
  644.  
  645. online(x,y) {
  646.     return(x==u.ux || y==u.uy ||
  647.         (x-u.ux)*(x-u.ux) == (y-u.uy)*(y-u.uy));
  648. }
  649.